feat(bitcoin-wallet-snap): add batch proof-of-ownership signing - #266
feat(bitcoin-wallet-snap): add batch proof-of-ownership signing#266hmalik88 wants to merge 15 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/bitcoin-wallet-snap/snap.manifest.json
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| const { index, accountId } = signingRequests[ | ||
| signingRequestIndex | ||
| ] as (typeof signingRequests)[number]; | ||
| const { error } = signedMessage as { error?: string }; | ||
|
|
||
| if (error !== undefined) { | ||
| results[index] = { accountId, error }; | ||
| return; | ||
| } | ||
|
|
||
| const { signature } = signedMessage as { signature: string }; | ||
| results[index] = { accountId, signature }; |
There was a problem hiding this comment.
Similar comments than for Solana here: #256 (comment)
| 'Failed to sign message', | ||
| { | ||
| id: account.id, | ||
| message, |
There was a problem hiding this comment.
I don't think we are logging the message being signed in Solana? 🤔 not sure we should have it here either, WDYT? Yes it's supposed to be a public message, but just in case (future-proofing)
| const results: SignProofOfOwnershipBatchResponse['results'] = new Array( | ||
| items.length, | ||
| ); |
There was a problem hiding this comment.
I think we should use the length of uniqueAccountIds here because there may be duplicates.
There was a problem hiding this comment.
I think this needs to stay as items.length. The response is per input item and preserves input order, so duplicate account IDs still need duplicate result slots.
| message: string; | ||
| }[] = []; | ||
|
|
||
| items.forEach(({ accountId, message }, index) => { |
There was a problem hiding this comment.
Can we just use the array of unique id here?
There was a problem hiding this comment.
uniqueAccountIds is only for fetching accounts; it drops the item index and message, which we need for validation/signing and for putting results back in the right positions.
|



Explanation
This PR adds
signProofOfOwnershipBatchsupport to the Bitcoin Wallet Snap.The new method lets MetaMask request proof-of-ownership signatures for multiple Bitcoin accounts in one Snap RPC call. The response preserves input order and returns per-item success/error results, so one invalid account or message does not fail the entire batch.
References
N/A
Checklist